import React from 'react'
import { useSelector,useDispatch } from 'react-redux'


const Home = () => {
    const list = useSelector((state)=>state.list);
    // const {list} = useSelector((state)=>state)     //两种获取形式

    const dispatch = useDispatch();
    const add = () =>{
        dispatch({type:'add_item',payload:200})  //type名为add-item

    }
    return (
        <div>
            首页<button onClick={add}>添加</button>
            <ul>
                {
                    list.map(item=><li>{item}</li>)
                }
            </ul>
        </div>
    )
}

export default Home
